<pre class='metadata'>
Title: AVC (H.264) WebCodecs Registration
Repository: w3c/webcodecs
Status: NOTE-ED
Shortname: webcodecs-avc-codec-registration
Level: none
Group: mediawg
ED: https://w3c.github.io/webcodecs/avc_codec_registration.html
TR: https://www.w3.org/TR/webcodecs-avc-codec-registration/
Editor: Paul Adenot, w3cid 62410, Mozilla https://www.mozilla.org/
Editor: Eugene Zemtsov, w3cid 139375, Google LLC https://www.google.com/
Former Editor: Bernard Aboba, w3cid 65611, Microsoft Corporation https://www.microsoft.com/
Former Editor: Chris Cunningham, w3cid 114832, Google Inc. https://www.google.com/

Abstract: This registration is entered into the [[webcodecs-codec-registry]].
    It describes, for AVC (H.264), the (1) fully qualified [[WEBCODECS#config-codec-string|codec strings]],
    (2) the codec-specific {{EncodedVideoChunk}}
    {{EncodedVideoChunk/[[internal data]]}} bytes, (3) the
    {{VideoDecoderConfig/description|VideoDecoderConfig.description}} bytes,
    (4) the values of {{EncodedVideoChunk}} {{EncodedVideoChunk/[[type]]}},
    (5) the codec-specific extensions to {{VideoEncoderConfig}}, and
    (6) the codec-specific extensions to {{VideoEncoderEncodeOptions}}.

    The registration is not intended to include any information on whether a
    codec format is encumbered by intellectual property claims. Implementers and
    authors are advised to seek appropriate legal counsel in this matter if they
    intend to implement or use a specific codec format. Implementers of
    WebCodecs are not required to support the AVC / H.264 codec.

    This registration is non-normative.

Markup Shorthands:css no, markdown yes, dfn yes
!Participate: <a href="https://github.com/w3c/webcodecs">Git Repository.</a>
!Participate: <a href="https://github.com/w3c/webcodecs/issues/new">File an issue.</a>
!Version History: <a href="https://github.com/w3c/webcodecs/commits">https://github.com/w3c/webcodecs/commits</a>
</pre>

<pre class='biblio'>
{
  "ITU-T-REC-H.264": {
    "href": "https://www.itu.int/rec/T-REC-H.264",
    "title": "H.264 : Advanced video coding for generic audiovisual services",
    "publisher": "ITU",
    "date": "June 2019"
  },
  "iso14496-15": {
    "href": "https://www.iso.org/standard/89118.html",
    "title": "ISO/IEC 14496-15:2024 Information technology — Coding of audio-visual objects — Part 15: Carriage of network abstraction layer (NAL) unit structured video in the ISO base media file format",
    "publisher": "ISO",
    "date": "October 2024"
  }
}
</pre>

Fully qualified codec strings {#fully-qualified-codec-strings}
==============================================================

The [[WEBCODECS#config-codec-string|codec string]] begins with the prefix "avc1." or "avc3.", with a suffix of 6
characters as described respectively in Section 3.4 of [[rfc6381]] and Section
5.4.1 of [[iso14496-15]].

EncodedVideoChunk data {#encodedvideochunk-data}
================================================

{{EncodedVideoChunk}} {{EncodedVideoChunk/[[internal data]]}} is expected to be
an access unit as defined in [[ITU-T-REC-H.264]] section 7.4.1.2.

NOTE: An access unit contains exactly one primary coded picture.

If the bitstream is in {{AvcBitstreamFormat/avc}} format,
{{EncodedVideoChunk/[[internal data]]}} is assumed to be in canonical format, as
defined in [[iso14496-15]] section 5.3.2.

If the bitstream is in {{AvcBitstreamFormat/annexb}} format,
{{EncodedVideoChunk/[[internal data]]}} is assumed to be in in Annex B format,
as defined in [[ITU-T-REC-H.264]] Annex B.

NOTE: Since {{EncodedVideoChunk/[[internal data]]}} is inherently byte-aligned,
    implementations are not required to recover byte-alignment.

VideoDecoderConfig description {#videodecoderconfig-description}
================================================================

If the {{VideoDecoderConfig/description}} is present, it is assumed to be an
`AVCDecoderConfigurationRecord`, as defined by [[iso14496-15]], section
5.3.3.1, and the bitstream is assumed to be in {{AvcBitstreamFormat/avc}}
format.

NOTE: This format is commonly used in .MP4 files, where the player generally
    has random access to the media data.

If the {{VideoDecoderConfig/description}} is not present, the bitstream is
assumed to be in {{AvcBitstreamFormat/annexb}} format.

NOTE: "annexb" format is described in greater detail by [[ITU-T-REC-H.264]],
    Annex B. This format is commonly used in live-streaming applications, where
    including the SPS and PPS data periodically allows users to easily start
    from the middle of the stream.

EncodedVideoChunk type {#encodedvideochunk-type}
================================================

If an {{EncodedVideoChunk}}'s {{EncodedVideoChunk/[[type]]}} is
{{EncodedVideoChunkType/key}}, and the bitstream is in
{{AvcBitstreamFormat/avc}} format, then the {{EncodedVideoChunk}} is expected to
contain a primary coded picture that is an instantaneous decoding refresh (IDR)
picture.

NOTE: If the bitstream is in {{AvcBitstreamFormat/avc}} format, parameter sets
    necessary for decoding are included in
    {{VideoDecoderConfig/description|VideoDecoderConfig.description}}.

If an {{EncodedVideoChunk}}'s {{EncodedVideoChunk/[[type]]}} is
{{EncodedVideoChunkType/key}}, and the bitstream is in
{{AvcBitstreamFormat/annexb}} format, then the {{EncodedVideoChunk}} is expected
to contain both a primary coded picture that is an instantaneous decoding
refresh (IDR) picture, and all parameter sets necessary to decode all video data
NAL units in the {{EncodedVideoChunk}}.

VideoEncoderConfig extensions {#videoencoderconfig-extensions}
==============================================================

<pre class='idl'>
<xmp>
partial dictionary VideoEncoderConfig {
  AvcEncoderConfig avc;
};
</xmp>
</pre>

<dl>
  <dt><dfn dict-member for=VideoEncoderConfig>avc</dfn></dt>
  <dd>
    Contains codec specific configuration options for the AVC (H.264) codec.
  </dd>
</dl>

AvcEncoderConfig {#avc-encoder-config}
--------------------------------------
<pre class='idl'>
<xmp>
dictionary AvcEncoderConfig {
  AvcBitstreamFormat format = "avc";
};
</xmp>
</pre>

<dl>
  <dt><dfn dict-member for=AvcEncoderConfig>format</dfn></dt>
  <dd>
    Configures the format of output {{EncodedVideoChunk}}s. See
    {{AvcBitstreamFormat}}.
  </dd>
</dl>

AvcBitstreamFormat {#avc-bitstream-format}
------------------------------------------
<pre class='idl'>
<xmp>
enum AvcBitstreamFormat {
  "annexb",
  "avc",
};
</xmp>
</pre>

The {{AvcBitstreamFormat}} determines the location of AVC parameter sets, and
mechanisms for packaging the bitstream.

<dl>
  <dt><dfn enum-value for=AvcBitstreamFormat>annexb</dfn></dt>
  <dd>
    SPS and PPS data are included periodically throughout the bitstream.

    NOTE: This format is described in greater detail by [[ITU-T-REC-H.264]],
        Annex B. This format is commonly used in live-streaming applications,
        where including the SPS and PPS data periodically allows users to easily
        start from the middle of the stream.
  </dd>
  <dt><dfn enum-value for=AvcBitstreamFormat>avc</dfn></dt>
  <dd>
    SPS and PPS data are not included in the bitstream and are instead emitted
    via the {{VideoEncoder/[[output callback]]}} as the
    {{VideoDecoderConfig/description|VideoDecoderConfig.description}} of the
    {{EncodedVideoChunkMetadata/decoderConfig|EncodedVideoChunkMetadata.decoderConfig}}.

    NOTE: This format is described in greater detail by [[iso14496-15]],
        section 5.3. This format is commonly used in .MP4 files, where the
        player generally has random access to the media data.
</dl>

VideoEncoderEncodeOptions extensions {#videoencoderencodeoptions-extensions}
==============================================================

<pre class='idl'>
<xmp>
partial dictionary VideoEncoderEncodeOptions {
  VideoEncoderEncodeOptionsForAvc avc;
};
</xmp>
</pre>

<dl>
  <dt><dfn dict-member for=VideoEncoderEncodeOptions>avc</dfn></dt>
  <dd>
    Contains codec specific encode options for the [[ITU-T-REC-H.264]] codec.
  </dd>
</dl>

VideoEncoderEncodeOptionsForAvc {#avc-encode-options}
--------------------------------------
<pre class='idl'>
<xmp>
dictionary VideoEncoderEncodeOptionsForAvc {
  unsigned short? quantizer;
};
</xmp>
</pre>

<dl>
  <dt><dfn dict-member for=VideoEncoderEncodeOptionsForAvc>quantizer</dfn></dt>
  <dd>
    Sets per-frame quantizer value.
    In [[ITU-T-REC-H.264]] the quantizer threshold can be varied from 0 to 51.
  </dd>
</dl>

Privacy Considerations {#privacy-considerations}
==========================================================================

Please refer to the section [[WEBCODECS#privacy-considerations|Privacy
Considerations]] in [[WEBCODECS]].

Security Considerations {#security-considerations}
==========================================================================

Please refer to the section [[WEBCODECS#security-considerations|Security
Considerations]] in [[WEBCODECS]].
